package com.ymatou.iapi.productcategory.testcase;

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonElement;
import com.shop2cn.iapi.productcategory.parameter.CallSyncMongoBean;
import com.shop2cn.iapi.productcategory.service.CallSyncMongoCall;
import com.shop2cn.iapi.agentproducts.service.CategoryListCall;
import com.ymatou.iapi.productcategory.parameter.BrandAliasDto;
import com.ymatou.iapi.productcategory.parameter.BrandCategoryDto;
import com.ymatou.iapi.productcategory.parameter.BrandDto;
import com.ymatou.iapi.productcategory.parameter.CatalogsTagDto;
import com.ymatou.iapi.productcategory.parameter.CountryDto;
import com.ymatou.iapi.productcategory.parameter.GetBrandByIdBean;
import com.ymatou.iapi.productcategory.parameter.SaveBrandBean;
import com.ymatou.iapi.productcategory.service.SaveBrandCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.mongo.BuyerProductWapper;
import com.ymttest.database.mongo.ProductBrandInfoWapper;
import com.ymttest.utils.TestDataManager;
/**
*保存&修改品牌信息（后台）
*FreeMaker Template自动生成代码
*/
@TestSuite
@Ignore
public class Ts_SaveBrand{
	private static SaveBrandBean savebrandBean;
	private static SaveBrandCall savebrandCall;
	IntergratedProductMapper ipm ;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("保存&修改品牌信息（后台）");
	}

	@Before
	public void caseUp() {
		savebrandBean=new SaveBrandBean();
		savebrandCall=new SaveBrandCall();
		ipm = SqlMapperFactory
				.getIntergratedProductMapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(savebrandCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void verifyDB(SaveBrandBean savebrandBean2, Integer bid) {
		Map<String, Object> m = ipm.selectBrandByBrandId(bid);
		Logger.debug(m);
		//{"CnName":"测试品牌005号","KeyWord":"T","CountryId":4,"CategoryList":[{"MasterCategoryId":10881,"CategoryId":10086,"CategoryName":"书籍是人lei的阶梯","CategoryEnName":"hhahhha","CategoryPath":"书籍 -> 四大名著 -> 西游记","Level":2}],"ComnCountryList":[{"CountryId":1,"CountryName":"中国","ContinentName":"湖北省"}],"Description":"这是一条测试数据","LogoUrl":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg","BannerUrl":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg","AliasList":[{"Id":1,"Name":"玄幻之祖"}],"Founder":"孙悟空","UpdatUser":"猪八戒","EnName":"357358024","DefaultName":1,"Type":2}
		//{sBrand=测试品牌005号, sWebSite=null, sBrandEn=357358024, mBrandDescript=这是一条测试数据, iSort=0, show=false, generalName=null, iAttention=null, otherTags=null, 
		//iBrandId=27618, iLevel=0, bIsDisplay=true, sFounder=孙悟空, sLogoUrl=https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&
		//src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg, sKey=T, iCountryId=4, generalType=null, sBannerUrl=https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg, sUpdateUser=null, 
		//sBrandType=2, sBizSector=null, dAddTime=2020-05-09 17:07:31.39, sOperator=孙悟空, mBrandDescriptEn=null, iSortRule=0, DataVersion=[B@18920cc, iDefaultName=1, iAction=0, dUpdateTime=null}
		Logger.verifyEquals(savebrandBean2.getCnName(), m.get("sBrand").toString(), "验证sBrand");
		Logger.verifyEquals(savebrandBean2.getEnName(), m.get("sBrandEn").toString(), "验证sBrandEn");
		Logger.verifyEquals(savebrandBean2.getDescription(), m.get("mBrandDescript").toString(), "验证mBrandDescript");
		Logger.verifyEquals(bid.toString(), m.get("iBrandId").toString(), "验证iBrandId");
		Logger.verifyEquals(savebrandBean2.getFounder(), m.get("sFounder").toString(), "验证sFounder");
		Logger.verifyEquals(savebrandBean2.getLogoUrl(), m.get("sLogoUrl").toString(), "验证sLogoUrl");
		Logger.verifyEquals(savebrandBean2.getBannerUrl(), m.get("sBannerUrl").toString(), "验证sBannerUrl");
		Logger.verifyEquals(savebrandBean2.getKeyWord(), m.get("sKey").toString(), "验证sKey");
		Logger.verifyEquals(savebrandBean2.getCountryId().toString(), m.get("iCountryId").toString(), "验证iCountryId");
		Logger.verifyEquals(savebrandBean2.getBannerUrl(), m.get("sBannerUrl").toString(), "验证sBannerUrl");
		Logger.verifyEquals(savebrandBean2.getType().toString(), m.get("sBrandType").toString(), "验证sBrandType");
		Logger.verifyEquals(savebrandBean2.getFounder(), m.get("sOperator").toString(), "验证sOperator");
		if(savebrandBean2.getShow()!=null) {
			Logger.verifyEquals(savebrandBean2.getShow().toString(), m.get("show").toString(), "验证show");
		}
		if(savebrandBean2.getGeneralName()!=null) {
			Logger.verifyEquals(savebrandBean2.getGeneralName(), m.get("generalName").toString(), "验证generalName");
		}
		if(savebrandBean2.getGeneralType()!=null) {
			Logger.verifyEquals(savebrandBean2.getGeneralType().toString(), m.get("generalType").toString(), "验证generalType");
		}
		if(savebrandBean2.getOtherTags()!=null) {
			Logger.verifyEquals(savebrandBean2.getOtherTags(), m.get("otherTags").toString(), "验证otherTags");
		}
		if(savebrandBean2.getBrandTagList()!=null&&savebrandBean2.getBrandTagList().size()>0) {
			List<Map<String, Object>> dbs = ipm.selectBrandTagByBrandId(bid);
			Logger.debug("dbs:"+dbs);
			savebrandBean2.getBrandTagList().forEach(x->{
				Map<String, Object> dbv= dbs.stream().filter(y->{return y.get("TagId").toString().equals(x.getTagId().toString());}).findAny().get();
				Logger.verifyEquals(x.getBrandTagValue(), dbv.get("TagValue").toString(), "验证TagValue");
			});
			
		}
		
	}
	
	
	private void verifyMongoDB(SaveBrandBean savebrandBean, Integer BrandId) throws Exception {
		Map<String, Object> m = new ProductBrandInfoWapper().getProductBrandInfoById(BrandId).get(0);
		Logger.debug(m);
		Logger.verifyEquals(savebrandBean.getCnName(), m.get("BrandName").toString(), "验证BrandName");
		Logger.verifyEquals(savebrandBean.getEnName(), m.get("BrandEnName").toString(), "验证BrandEnName");
		Logger.verifyEquals(BrandId.toString(), m.get("BrandId").toString(), "验证BrandId");
		
		Logger.verifyEquals(savebrandBean.getKeyWord(), m.get("KeyWord").toString(), "验证sKey");
		Logger.verifyEquals(savebrandBean.getBannerUrl(), m.get("BrandBannerUrl").toString(), "验证BrandBannerUrl");
		Logger.verifyEquals(savebrandBean.getLogoUrl(), m.get("BrandLogoUrl").toString(), "验证BrandLogoUrl");
		Logger.verifyEquals(savebrandBean.getFounder(), m.get("CreateUser").toString(), "验证CreateUser");
		Logger.verifyEquals(savebrandBean.getCountryId()+"", m.get("CountryId").toString(), "验证CountryId");
		
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBrand_001() {
		Logger.start(true,"保存&修改品牌信息（后台）");
		try {
//			Integer abs = Math.abs(TestDataManager.getRandomIntNum(10));
			savebrandBean.setCnName("测试品牌005号");
			savebrandBean.setEnName("EnName");
			savebrandBean.setKeyWord("T");
			savebrandBean.setCountryId(004);
			savebrandBean.setDefaultName(1);
			savebrandBean.setType(2);
			BrandCategoryDto brandCategoryDto = new BrandCategoryDto();
			brandCategoryDto.setCategoryEnName("hhahhha");
			brandCategoryDto.setCategoryId(10086);
			brandCategoryDto.setCategoryName("书籍是人lei的阶梯");
			brandCategoryDto.setCategoryPath("书籍 -> 四大名著 -> 西游记");
			brandCategoryDto.setLevel(2);
			brandCategoryDto.setMasterCategoryId(10881);
			List<BrandCategoryDto> categoryList = new ArrayList<BrandCategoryDto>();
			categoryList.add(brandCategoryDto);
			
			savebrandBean.setCategoryList(categoryList);
			CountryDto countryDto = new CountryDto();
			countryDto.setContinentName("湖北省");
			countryDto.setCountryId(001);
			countryDto.setCountryName("中国");
			List<CountryDto> comnCountryList = new ArrayList<CountryDto>();
			comnCountryList.add(countryDto);
			
			savebrandBean.setComnCountryList(comnCountryList);
			savebrandBean.setDescription("这是一条测试数据");
			savebrandBean.setLogoUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg");
			savebrandBean.setBannerUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg");
			BrandAliasDto brandAliasDto = new BrandAliasDto();
			brandAliasDto.setId(0001);
			brandAliasDto.setName("玄幻之祖");
			List<BrandAliasDto> aliasList = new ArrayList<BrandAliasDto>();
			aliasList.add(brandAliasDto);
			
			savebrandBean.setAliasList(aliasList);
			savebrandBean.setFounder("孙悟空");
			savebrandBean.setUpdatUser("猪八戒");
			
			savebrandCall.setData(savebrandBean);
			savebrandCall.callService();			
			String Code = savebrandCall.getString("Code");
			Logger.verifyEquals("200", Code, "验证Code");
			Integer bid=savebrandCall.getBrandId();
			verifyDB(savebrandBean,bid);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBrand_002() {
		Logger.start(true,"保存&修改品牌信息（后台）");
		try {
			Map<String, Object> m = ipm.selectBrandsByBrandEn("EnName").get(0);
			savebrandBean.setId(Integer.valueOf(m.get("iBrandId").toString()));
			savebrandBean.setCnName("测试品牌002号");
			savebrandBean.setEnName("EnName");
			
			savebrandBean.setKeyWord("T");
			savebrandBean.setCountryId(001);
			savebrandBean.setDefaultName(1);
			savebrandBean.setType(1);
			BrandCategoryDto brandCategoryDto = new BrandCategoryDto();
			brandCategoryDto.setCategoryEnName("xiyouji");
			brandCategoryDto.setCategoryId(1086);
			brandCategoryDto.setCategoryName("书籍");
			brandCategoryDto.setCategoryPath("书籍 -> 四大名著 -> 西游记");
			brandCategoryDto.setLevel(3);
			brandCategoryDto.setMasterCategoryId(1088);
			List<BrandCategoryDto> categoryList = new ArrayList<BrandCategoryDto>();
			categoryList.add(brandCategoryDto);
			
			savebrandBean.setCategoryList(categoryList);
			CountryDto countryDto = new CountryDto();
			countryDto.setContinentName("湖北省");
			countryDto.setCountryId(001);
			countryDto.setCountryName("中国");
			List<CountryDto> comnCountryList = new ArrayList<CountryDto>();
			comnCountryList.add(countryDto);
			
			
			savebrandBean.setComnCountryList(comnCountryList);
			savebrandBean.setDescription("这是一条测试数据");
			savebrandBean.setLogoUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg");
			savebrandBean.setBannerUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg");
			BrandAliasDto brandAliasDto = new BrandAliasDto();
			brandAliasDto.setId(0001);
			brandAliasDto.setName("玄幻之祖");
			List<BrandAliasDto> aliasList = new ArrayList<BrandAliasDto>();
			aliasList.add(brandAliasDto);
			
			savebrandBean.setAliasList(aliasList);
			savebrandBean.setFounder("孙悟空");
			savebrandBean.setUpdatUser("猪八戒");
			
			savebrandCall.setData(savebrandBean);
			savebrandCall.callService();		
			Logger.verifyEquals("200", savebrandCall.getString("Code"), "验证Code");
			Integer BrandId = savebrandCall.getBrandId();
			Logger.verifyEquals(savebrandBean.getId(), BrandId, "验证id");
			verifyDB(savebrandBean,BrandId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBrand_003() {
		Logger.start(true,"保存&修改品牌信息（后台）-新增品牌标签");
		try {
//			GeneralType	int	O	通用显示类型	0-英文 1中文 2其他
//			GeneralName	String	 	通用显示名	大牌
//			Show	boolean	M	前端是否展示	true-展示 false-不展示
//			OtherTags	String	 	其他标签	bala,bala
//			CatalogsTagList	List<CatalogsTagDto>	O	
//			TagId	int	O	标签id	 
//			CatalogId	int	O	类目id	 
//			BrandTagValue	String	O	 	bala,bala
			 
			Integer abs = Math.abs(TestDataManager.getRandomIntNum(10));
			savebrandBean.setGeneralType(2);
			savebrandBean.setGeneralName("通用显示名大牌");
			savebrandBean.setShow(true);
			savebrandBean.setOtherTags("other,test");
			List<CatalogsTagDto> catalogsTagList=new ArrayList<CatalogsTagDto>();
			CatalogsTagDto c=new CatalogsTagDto();
			c.setTagId(1);
			c.setBrandTagValue("brandtagvalue");
			catalogsTagList.add(c);
			savebrandBean.setBrandTagList(catalogsTagList);
			savebrandBean.setCnName("测试品牌005号");
			savebrandBean.setEnName(abs.toString());
			savebrandBean.setKeyWord("T");
			savebrandBean.setCountryId(004);
			savebrandBean.setDefaultName(1);
			savebrandBean.setType(2);
			BrandCategoryDto brandCategoryDto = new BrandCategoryDto();
			brandCategoryDto.setCategoryEnName("hhahhha");
			brandCategoryDto.setCategoryId(10086);
			brandCategoryDto.setCategoryName("书籍是人lei的阶梯");
			brandCategoryDto.setCategoryPath("书籍 -> 四大名著 -> 西游记");
			brandCategoryDto.setLevel(2);
			brandCategoryDto.setMasterCategoryId(10881);
			List<BrandCategoryDto> categoryList = new ArrayList<BrandCategoryDto>();
			categoryList.add(brandCategoryDto);
			
			savebrandBean.setCategoryList(categoryList);
			CountryDto countryDto = new CountryDto();
			countryDto.setContinentName("湖北省");
			countryDto.setCountryId(001);
			countryDto.setCountryName("中国");
			List<CountryDto> comnCountryList = new ArrayList<CountryDto>();
			comnCountryList.add(countryDto);
			
			savebrandBean.setComnCountryList(comnCountryList);
			savebrandBean.setDescription("这是一条测试数据");
			savebrandBean.setLogoUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg");
			savebrandBean.setBannerUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg");
			BrandAliasDto brandAliasDto = new BrandAliasDto();
			brandAliasDto.setId(0001);
			brandAliasDto.setName("玄幻之祖");
			List<BrandAliasDto> aliasList = new ArrayList<BrandAliasDto>();
			aliasList.add(brandAliasDto);
			
			savebrandBean.setAliasList(aliasList);
			savebrandBean.setFounder("孙悟空");
			savebrandBean.setUpdatUser("猪八戒");
			
			savebrandCall.setData(savebrandBean);
			savebrandCall.callService();			
			String Code = savebrandCall.getString("Code");
			Logger.verifyEquals("200", Code, "验证Code");
			Integer bid=savebrandCall.getBrandId();
			verifyDB(savebrandBean,bid);
//			 {sBrand=测试品牌005号, sWebSite=null, sBrandEn=460104590, mBrandDescript=这是一条测试数据, iSort=0, show=false, generalName=null, iAttention=null, otherTags=null, iBrandId=27639, iLevel=0, bIsDisplay=true, sFounder=孙悟空, sLogoUrl=https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg, sKey=T, iCountryId=4, generalType=null, sBannerUrl=https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg, sUpdateUser=null, sBrandType=2, sBizSector=null, dAddTime=2020-05-11 18:44:20.613, sOperator=孙悟空, mBrandDescriptEn=null, iSortRule=0, DataVersion=[B@18920cc, iDefaultName=1, iAction=0, dUpdateTime=null}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBrand_004() {
		Logger.start(true,"保存&修改品牌信息（后台），回调神器同步");
		try {
			savebrandBean.setCnName("测试品牌013211235号");
			savebrandBean.setEnName(TestDataManager.randomStr(8));
			savebrandBean.setKeyWord("T");
			savebrandBean.setCountryId(004);
			savebrandBean.setDefaultName(1);
			savebrandBean.setType(2);
			BrandCategoryDto brandCategoryDto = new BrandCategoryDto();
			brandCategoryDto.setCategoryEnName("h1hahhha");
			brandCategoryDto.setCategoryId(10086);
			brandCategoryDto.setCategoryName("书籍是人lei的阶梯1");
			brandCategoryDto.setCategoryPath("书籍 -> 四大名著 -> 西游记1");
			brandCategoryDto.setLevel(2);
			brandCategoryDto.setMasterCategoryId(10881);
			List<BrandCategoryDto> categoryList = new ArrayList<BrandCategoryDto>();
			categoryList.add(brandCategoryDto);
			
			savebrandBean.setCategoryList(categoryList);
			CountryDto countryDto = new CountryDto();
			countryDto.setContinentName("湖北省");
			countryDto.setCountryId(001);
			countryDto.setCountryName("中国");
			List<CountryDto> comnCountryList = new ArrayList<CountryDto>();
			comnCountryList.add(countryDto);
			
			savebrandBean.setComnCountryList(comnCountryList);
			savebrandBean.setDescription("这是一条测试数据");
			savebrandBean.setLogoUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg");
			savebrandBean.setBannerUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg");
			BrandAliasDto brandAliasDto = new BrandAliasDto();
			brandAliasDto.setId(0001);
			brandAliasDto.setName("玄幻之祖");
			List<BrandAliasDto> aliasList = new ArrayList<BrandAliasDto>();
			aliasList.add(brandAliasDto);
			
			savebrandBean.setAliasList(aliasList);
			savebrandBean.setFounder("孙悟空");
			savebrandBean.setUpdatUser("猪八戒");
			
			savebrandCall.setData(savebrandBean);
			savebrandCall.callService();			
			String Code = savebrandCall.getString("Code");
			Logger.verifyEquals("200", Code, "验证Code");
			Integer BrandId=savebrandCall.getBrandId();
			verifyDB(savebrandBean,BrandId);
			syncMongo(BrandId);
			verifyMongoDB(savebrandBean, BrandId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBrand_005() {
		Logger.start(true,"保存&修改品牌信息（后台），不回调神器同步，神器数据库没有");
		try {
			Map<String, Object> m = ipm.selectBrandsByBrandEn("EnName").get(0);
			savebrandBean.setId(Integer.valueOf(m.get("iBrandId").toString()));
			savebrandBean.setCnName("测试品牌002号");
			savebrandBean.setEnName("EnName");
			
			savebrandBean.setKeyWord("T");
			savebrandBean.setCountryId(001);
			savebrandBean.setDefaultName(1);
			savebrandBean.setType(1);
			BrandCategoryDto brandCategoryDto = new BrandCategoryDto();
			brandCategoryDto.setCategoryEnName("xiyouji");
			brandCategoryDto.setCategoryId(1086);
			brandCategoryDto.setCategoryName("书籍");
			brandCategoryDto.setCategoryPath("书籍 -> 四大名著 -> 西游记");
			brandCategoryDto.setLevel(3);
			brandCategoryDto.setMasterCategoryId(1088);
			List<BrandCategoryDto> categoryList = new ArrayList<BrandCategoryDto>();
			categoryList.add(brandCategoryDto);
			
			savebrandBean.setCategoryList(categoryList);
			CountryDto countryDto = new CountryDto();
			countryDto.setContinentName("湖北省");
			countryDto.setCountryId(001);
			countryDto.setCountryName("中国");
			List<CountryDto> comnCountryList = new ArrayList<CountryDto>();
			comnCountryList.add(countryDto);
			
			
			savebrandBean.setComnCountryList(comnCountryList);
			savebrandBean.setDescription("这是一条测试数据");
			savebrandBean.setLogoUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271935029&di=c20549998621dfd6ee14b41b92db97fa&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F018373556848c8000001271679582d.jpg");
			savebrandBean.setBannerUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533271995519&di=9f040e778034bf7381c75488e063d03f&imgtype=0&src=http%3A%2F%2Fwww.jituwang.com%2Fuploads%2Fallimg%2F140428%2F259428-14042PS62466.jpg");
			BrandAliasDto brandAliasDto = new BrandAliasDto();
			brandAliasDto.setId(0001);
			brandAliasDto.setName("玄幻之祖");
			List<BrandAliasDto> aliasList = new ArrayList<BrandAliasDto>();
			aliasList.add(brandAliasDto);
			
			savebrandBean.setAliasList(aliasList);
			savebrandBean.setFounder("孙悟空");
			savebrandBean.setUpdatUser("猪八戒");
			
			savebrandCall.setData(savebrandBean);
			savebrandCall.callService();		
			Logger.verifyEquals("200", savebrandCall.getString("Code"), "验证Code");
			Integer BrandId = savebrandCall.getBrandId();
			Logger.verifyEquals(savebrandBean.getId(), BrandId, "验证id");
			verifyDB(savebrandBean,BrandId);
			syncMongo(BrandId);
			
			ArrayList<Map> productBrandInfoByBrandId = new ProductBrandInfoWapper().getProductBrandInfoByBrandId(BrandId);
			System.out.println(productBrandInfoByBrandId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	private void syncMongo(int BrandId) throws ClientProtocolException, IOException{
		CallSyncMongoBean callsyncmongoBean = new CallSyncMongoBean();
		CallSyncMongoCall callsyncmongoCall = new CallSyncMongoCall();
		
		callsyncmongoBean.setBrandId(BrandId);
		callsyncmongoCall.setData(callsyncmongoBean);
		callsyncmongoCall.callService();	
		
		Logger.verifyEquals("ok", callsyncmongoCall.getReturnData(), "验证code");
		
	}
	
}